<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <title>区域限制</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0">
    <style>
        html, body, #map {
            height: 100%;
            margin: 0;
        }
    </style>
    <script src="https://api.map.baidu.com/api?v=1.0&type=webgl&ak=E4805d16520de693a3fe707cdc962045"></script>
    <script src="../src/AreaRestriction.js"></script>
</head>
<body>
    <div id="map"></div>
</body>
</html>
<script>
    var map = new BMapGL.Map("map");
    map.centerAndZoom(new BMapGL.Point(116.404, 39.915), 13);
    map.enableScrollWheelZoom();

    var bound = new BMapGL.Bounds(new BMapGL.Point(116.027143, 39.772348), new BMapGL.Point(116.832025, 40.126349));
    map.addOverlay(new BMapGL.Polygon([
        new BMapGL.Point(bound.sw.lng, bound.sw.lat),
        new BMapGL.Point(bound.sw.lng, bound.ne.lat),
        new BMapGL.Point(bound.ne.lng, bound.ne.lat),
        new BMapGL.Point(bound.ne.lng, bound.sw.lat)
    ]))

    try {	
        BMapGLLib.AreaRestriction.setBounds(map, bound);
    } catch (e) {
        alert(e);
    }
</script>